#ifndef CONSTANT_HH
# define CONSTANT_HH

# include "signal.hh"

namespace funky {

  template <typename Sample>
  struct constant {
  private:
    Sample sample;
  public:
    explicit constant(const Sample& sample): sample(sample) {}
    explicit constant(Sample&& sample): sample(std::move(sample)) {}
    constant(const constant&) = default;
    constant(constant&& other):
      sample(std::move(other.sample)) {}

    constant& operator++() {
      return *this;
    }

    constant& operator++(int) {
      return *this;
    }

    template <typename D>
    constant& operator+=(const D&) {
      return *this;
    }

    Sample operator*() const {
      return sample;
    }
  };

  template <typename T>
  struct signal_traits<constant<T> > {
    typedef T sample;
    typedef size_t duration;
  };

}

#endif
